import "@babel/polyfill";
import Vue from "vue";
import Vuex from "vuex";
// todo: 实验如何写入到babel.config.js中

import "@/common/common.less";

import ElementUi from "element-ui";
import VueToast from "vue-toasted";
import layout from "@/layout/";
import PostFlow from "@/pages/home/PostFlow.vue";
import router from "./router/";
// import '@/plugins/rem'
Vue.use(Vuex);

Vue.use(ElementUi);

Vue.use(VueToast);

Vue.component("jb-template", layout);

Vue.component("post-list", PostFlow);

import "@/plugins/schedulers/AccessScheduler";

import axios from "@/plugins/axios";

import ActivePanel from "batman-active-panel";
Vue.component("active-panel", ActivePanel);

import Zone from "@/pages/user/zone";
Vue.component("zone", Zone);

import Detail from "@/pages/home/detail";
Vue.component("post-detail", Detail);

new Vue({
  el: "#app",
  router,
  created() {
    const href = location.href;
    window.sign_href = href;
    axios({
      url: "weixin/web",
      method: "post",
      data: { url: href.split('#')[0] }
    }).then(data => {
      wx.ready(() => {
        const shareInfo = {
          title: "健蓓论坛",
          desc: "健蓓论坛",
          imgUrl:
            "https://img.yzcdn.cn/upload_files/2018/12/04/Fs2MKthTfft2XLKQbxIP98sTO5VH.jpg",
          link: location.href
        };

        wx.updateAppMessageShareData(shareInfo);
      });
      data.debug = false;
      data.jsApiList= ["updateAppMessageShareData"]
      wx.config(data);
    });
  }
});
